package com.jiyang.jyandroid.test02;

import android.content.DialogInterface;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import com.jiyang.jyandroid.BaseActivity;
import com.jiyang.jyandroid.R;

/**
 * Created by jy on 2016/12/1.
 * 简单列表项对话框
 */

public class Two_4Activity extends BaseActivity {
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Button button = new Button(this);
        button.setText("显示对话框");
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                new AlertDialog.Builder(Two_4Activity.this)
                        .setSingleChoiceItems(getResources().getStringArray(R.array.activity_name), 0, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialogInterface, int i) {
                                Toast.makeText(Two_4Activity.this, "你选择了:" + getResources().getStringArray(R.array.activity_name)[i], Toast.LENGTH_SHORT).show();
                                dialogInterface.dismiss();
                            }
                        })
                        .create().show();
            }
        });
        addContentView(button, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    }

}
